import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/Login.vue';
import Admin from '../views/Admin.vue';
import Teacher from '../views/Teacher.vue';
import FreeLabsComponent from '../components/FreeLabsComponent.vue';
import MyAppointmentsComponent from '../components/MyAppointmentsComponent.vue';
import MyScheduleComponent from '../components/MyScheduleComponent.vue';
import InquireClassSchedule from '../components/InquireClassSchedule.vue';
import ManagementCourse from '../components/ManagementCourse.vue';
import Zhuye from '../views/Zhuye.vue'; // 确保路径正确
import PartyHistory from '../views/PartyHistory.vue'; 
import Events from '../views/Events.vue'; 
import ContactUs from '../views/ContactUs.vue'; 

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login,
  },
  {
    path: '/admin',
    name: 'Admin',
    component: Admin,
    children: [
      { path: '/inquire-schedule', component: InquireClassSchedule },
    { path: '/management-course', component: ManagementCourse },
  
    ]
  },
  {
    path: '/teacher',
    name: 'Teacher',
    component: Teacher,
    children: [
    { path: '/free-labs', component: FreeLabsComponent },
  { path: '/my-appointments', component: MyAppointmentsComponent },
  { path: '/my-schedule', component: MyScheduleComponent },
  ]
  },
  {
    path: '/zhuye', // 定义路由的路径
    name: 'Zhuye', // 定义路由的名称，用于编程式导航
    component: Zhuye, // 指定路由要渲染的组件
  },
  {
    path: '/history', // 定义路由的路径
    name: 'PartyHistory', // 定义路由的名称，用于编程式导航
    component: PartyHistory, // 指定路由要渲染的组件
  },
  {
    path: '/events', // 定义路由的路径
    name: 'Events', // 定义路由的名称，用于编程式导航
    component: Events, // 指定路由要渲染的组件
  },
  {
    path: '/contact', // 定义路由的路径
    name: 'ContactUs', // 定义路由的名称，用于编程式导航
    component: ContactUs, // 指定路由要渲染的组件
  },
];

// 使用 import.meta.env 来访问环境变量
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL || '/'), // 如果没有定义 BASE_URL，则默认为 '/'
  routes,
});

export default router;